home *** CD-ROM | disk | FTP | other *** search
- head 2.3;
- branch ;
- access ;
- symbols no-auto-remigrate:2.1 installed:2.0;
- locks ; strict;
- comment @ * @;
-
-
- 2.3
- date 90.09.24.14.46.50; author douglis; state Exp;
- branches ;
- next 2.2;
-
- 2.2
- date 90.08.15.15.59.44; author douglis; state Exp;
- branches ;
- next 2.1;
-
- 2.1
- date 90.06.22.14.58.28; author douglis; state Exp;
- branches ;
- next 2.0;
-
- 2.0
- date 90.03.10.13.13.08; author douglis; state Stable;
- branches ;
- next 1.3;
-
- 1.3
- date 90.03.10.13.11.50; author douglis; state Exp;
- branches ;
- next 1.2;
-
- 1.2
- date 90.02.28.10.59.40; author douglis; state Exp;
- branches ;
- next 1.1;
-
- 1.1
- date 90.02.16.15.17.22; author douglis; state Exp;
- branches ;
- next ;
-
-
- desc
- @open the global or host-specific pdev.
- @
-
-
- 2.3
- log
- @added callback flag to MigHostCache to make it easier to flag all hosts as reclaimed after error
- @
- text
- @/*
- * MigOpenPdev.c --
- *
- * This file contains the MigOpenPdev procedure, which
- * opens the pseudo-device that communicates with
- * either the global server or the local daemon.
- *
- * Copyright 1990 Regents of the University of California
- * Permission to use, copy, modify, and distribute this
- * software and its documentation for any purpose and without
- * fee is hereby granted, provided that the above copyright
- * notice appear in all copies. The University of California
- * makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without
- * express or implied warranty.
- */
-
- #ifndef lint
- static char rcsid[] = "$Header: /sprite/src/lib/c/mig/RCS/MigOpenPdev.c,v 2.2 90/08/15 15:59:44 douglis Exp Locker: douglis $ SPRITE (Berkeley)";
- #endif not lint
-
- #include <fs.h>
- #include <stdio.h>
- #include <sys/file.h>
- #include <mig.h>
- #include "migInt.h"
-
- extern int errno;
- extern char *strerror();
-
- /*
- * Define the global variables that refer to the pdevs used. Initialize
- * them to -1 to indicate they haven't been opened.
- */
- int mig_GlobalPdev = -1;
- int mig_LocalPdev = -1;
-
-
- /*
- *----------------------------------------------------------------------
- *
- * MigOpenPdev --
- *
- * Open the specified pseudo-device. If global
- * is non-zero, open the global pdev, else
- * open the pdev for this host.
- *
- * Results:
- * If successful, 0 is returned. If an error is encountered,
- * then -1 is returned and errno indicates the error.
- *
- * Side effects:
- * One of the global variables defined above is updated to
- * store the descriptor. This variable is used in subsequent
- * accesses. Also, if we give up after exceeding the maximum
- * number of retries, we set a flag so in the future we only
- * try once rather than going through the full sleep-open-sleep
- * ritual.
- *
- *----------------------------------------------------------------------
- */
- int
- MigOpenPdev(global)
- int global; /* Whether to open the global pdev. */
- {
- int desc;
- char *name;
- int retries;
- int sleepTime;
- static int gaveUp = 0;
-
-
- if (global) {
- /*
- * Assume no hosts are assigned to us, and that any hosts previously
- * assigned have been revoked.
- */
- MigHostCache(0, MIG_CACHE_REMOVE_ALL, TRUE);
- }
- name = Mig_GetPdevName(global);
- if (name == (char *) NULL) {
- fprintf(stderr,
- "MigOpenPdev: Error getting name of pdev to open: %s.\n",
- strerror(errno));
- fflush(stderr);
- return(-1);
- }
- desc = open(name, O_RDONLY, 0);
- if (desc < 0) {
- if (!gaveUp) {
- gaveUp = 1;
- fprintf(stderr,
- "MigOpenPdev: Error opening pdev %s (still trying): %s.\n",
- name, strerror(errno));
- fflush(stderr);
- for (retries = 0, sleepTime = 1;
- retries < MIG_DAEMON_RETRY_COUNT;
- retries++, sleepTime *= 2) {
- sleep(sleepTime);
- desc = open(name, O_RDONLY, 0);
- if (desc >= 0) {
- fprintf(stderr,
- "MigOpenPdev: Succeeded in opening pdev.\n");
- fflush(stderr);
- break;
- }
- }
- if (retries == MIG_DAEMON_RETRY_COUNT) {
- fprintf(stderr,
- "MigOpenPdev: Unable to contact daemon.\n");
- fflush(stderr);
- return(-1);
- }
- } else {
- return(-1);
- }
- }
- if (global) {
- mig_GlobalPdev = desc;
- } else {
- mig_LocalPdev = desc;
- }
- gaveUp = 0;
- return(0);
- }
- @
-
-
- 2.2
- log
- @added fflushes.
- @
- text
- @d19 1
- a19 1
- static char rcsid[] = "$Header: /sprite/src/lib/c/mig/RCS/MigOpenPdev.c,v 2.1 90/06/22 14:58:28 douglis Exp Locker: douglis $ SPRITE (Berkeley)";
- d26 1
- d73 7
- @
-
-
- 2.1
- log
- @changes for alarms for timeouts with migd and for printing to stderr instead of syslog
- @
- text
- @d19 1
- a19 1
- static char rcsid[] = "$Header: /sprite/src/lib/c/mig/RCS/MigOpenPdev.c,v 2.0 90/03/10 13:13:08 douglis Stable Locker: douglis $ SPRITE (Berkeley)";
- d77 1
- d87 1
- d96 1
- d103 1
- @
-
-
- 2.0
- log
- @Changing version numbers.
- @
- text
- @d19 1
- a19 1
- static char rcsid[] = "$Header: /sprite/src/lib/c/mig/RCS/MigOpenPdev.c,v 1.3 90/03/10 13:11:50 douglis Exp Locker: douglis $ SPRITE (Berkeley)";
- a23 1
- #include <syslog.h>
- d74 1
- a74 1
- syslog(LOG_ERR,
- d83 1
- a83 1
- syslog(LOG_ERR,
- d92 2
- d98 1
- a98 1
- syslog(LOG_ERR,
- @
-
-
- 1.3
- log
- @changed when it prints syslog message
- @
- text
- @d19 1
- a19 1
- static char rcsid[] = "$Header: /sprite/src/lib/c/mig/RCS/MigOpenPdev.c,v 1.2 90/02/28 10:59:40 douglis Exp Locker: douglis $ SPRITE (Berkeley)";
- @
-
-
- 1.2
- log
- @if we give up after exceeding the maximum
- number of retries, we set a flag so in the future we only
- try once rather than going through the full sleep-open-sleep
- ritual.
- @
- text
- @d19 1
- a19 1
- static char rcsid[] = "$Header: /sprite/src/lib/c/mig/RCS/MigOpenPdev.c,v 1.1 90/02/16 15:17:22 douglis Exp Locker: douglis $ SPRITE (Berkeley)";
- d84 3
- d98 1
- a98 2
- "MigOpenPdev: Error opening pdev %s: %s.\n",
- name, strerror(errno));
- d110 1
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d19 1
- a19 1
- static char rcsid[] = "$Header: /sprite/src/lib/c/mig/RCS/MigOpenPdev.c,v 1.1 90/02/16 14:29:40 douglis Exp $ SPRITE (Berkeley)";
- d55 4
- a58 1
- * accesses.
- d70 1
- d80 21
- a100 6
- for (retries = 0, sleepTime = 1;
- retries < MIG_DAEMON_RETRY_COUNT;
- retries++, sleepTime *= 2) {
- desc = open(name, O_RDONLY, 0);
- if (desc >= 0) {
- break;
- a101 7
- sleep(sleepTime);
- }
- if (retries == MIG_DAEMON_RETRY_COUNT) {
- syslog(LOG_ERR,
- "MigOpenPdev: Error opening pdev %s: %s.\n",
- name, strerror(errno));
- return(-1);
- @
-